﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

public partial class DetailPage : System.Web.UI.Page
{
    public string linkSubject = "";
    public int subjectID;
    public string title;
    public int totalView;
    public int totalLike;
    public int totalComment;
    public string author;
    public string publishDate;
    public string original;
    public string content;
    public string metakey;
    public string subcontent;
    public string imageSubject;
    public string avatar = "/images/noavatar.png";
    public string host = ConfigurationManager.AppSettings["host"];
    public string modHost = ConfigurationManager.AppSettings["modHost"];
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //url =host+ Request.Url.AbsolutePath;

            subjectID = int.Parse(Request["subjectID"]);
            DBAccess.Object.Subject sb = DBAccess.Business.SubjectBusiness.GetSubjectDetail(subjectID);
            if (sb != null)
            {
                if (sb.Visible == 1)
                {
                    title = sb.Title;
                    content = HttpUtility.HtmlDecode(sb.Content);
                    totalComment = sb.TotalComment;
                    totalLike = sb.TotalLike;
                    totalView = sb.TotalView;
                    author = sb.AuthorName;
                    publishDate = Utilitys.ConvertToTimeVietName(sb.CreateDate);
                    original = sb.Original;
                    linkSubject = Utilitys.sefSubjectLink(subjectID, title);
                    subcontent = sb.Lead;
                    imageSubject = modHost + sb.ImagePath;
                    if (!string.IsNullOrEmpty(sb.Avatar))
                    {
                        avatar = modHost + sb.Avatar;
                    }
                    DBAccess.Business.SubjectBusiness.UpdateViewSubject(subjectID);
                }
                else
                {
                    Response.Redirect("/");
                }
            }
        }
        catch
        {

        }
    }
}